package com.vcg.community.filter;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.vcg.filter.beans.BaseEntity;
import com.vcg.filter.service.Service;
import com.vcg.filter.service.ServiceFactory;

/**
 * 数据转入到副本库;
 */
public class DataSwitcher {

     public void transform(String eventName, String sourceData){
         if (sourceData != null) {
             JSONObject json = JSON.parseObject(sourceData);
             Service service = ServiceFactory.getServiceImpl(json.getString("itemType"));
             BaseEntity baseEntity = service.get(json);
             service.save(baseEntity);
         }
    }

}
